package com.yima.baseproj.module.sys.user.role;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yima.baseproj.module.sys.role.SysRoleEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserRoleService extends ServiceImpl<SysUserRoleMapper, SysUserRoleEntity> {

    public List<SysRoleEntity> getUserRole(String userId) {
        return baseMapper.selectRoleByUser(userId);
    }

    public void delByUserId(String userId) {
        baseMapper.delete(Wrappers.<SysUserRoleEntity>query().eq("user_id",userId));
    }

    public Long countByRoleId(String roleId) {
        return count(Wrappers.<SysUserRoleEntity>query().eq("role_id",roleId));
    }
}